﻿using System.Collections;
using UnityEngine;
using XLua_Ki;

public class Coroutine_Demo : MonoBehaviour {

    void Start () {
        string mainABRoot = Application.dataPath + @"\XLua\MiniKimmy\Examples\02_XLuaCoroutine\streamingassets\MiniKimmy_XLuaCoroutine\";

        GameObject obj = new GameObject("MiniKimmy");
        obj.AddComponent<GameManager_Ki>();
        DontDestroyOnLoad(obj);

        StartCoroutine(TestRotateCube(mainABRoot));
    }

    IEnumerator TestRotateCube(string mainABRoot)
    {
        //GameManager.Instance.GetResourcesManager().LoadALLABPrefabs(mainABRoot);       //一次性加载prefab [选哪一种方式加载根据自己需要.]
        GameManager_Ki.Instance.GetResourcesManager_Ki().LoadALLABbundles(mainABRoot);   //先加载Bundle.根据情况再加载prefab

        Debug.Log("MiniKimmy : wait for 3s ...");
        int wait = 0;
        while (wait < 3)
        {
            wait++;
            Debug.Log("MiniKimmy :" + (3 - wait) + "...");
            yield return new WaitForSeconds(1f);
        }

        LuaUtil.CallLuaPathAction(GameManager_Ki.Instance.LuaEnv, "RotateCubeCtrl.TestStart");
    }
}
